﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Acms.Bll.Tests
{
    [TestClass]
    public class TemplateTests : Base
    {
        private void ValidateProperties(Acms.Bll.Template template, TestData.Template data)
        {
            Assert.AreEqual(template.Id, data.Id);
            AssertHelper.AreEqual((byte[])template.ConcurencyId, data.VersionId);
            Assert.AreEqual(template.ExcludeFromSearch, data.ExcludeFromSearch);
            Assert.AreEqual(template.Name, data.Name);
            Assert.AreEqual(template.NodeType, (Template.NodeTypes)data.NodeType);
            Assert.AreEqual(template.Notes, data.Notes);
            Assert.AreEqual(template.SiteId, data.SiteId);
        }

        [TestMethod]
        public void GetById_ReturnsNullWithIncorrectId()
        {
            Assert.IsNull(Acms.Bll.Template.GetById(int.MaxValue));
        }

        [TestMethod]
        public void GetById_ReturnsNotNullWithCorrectId()
        {
            Assert.IsNotNull(Acms.Bll.Template.GetById(_TestTemplates[0].Id));
        }

        [TestMethod]
        public void GetById_PopulatesCorrectly()
        {
            var tmp = Acms.Bll.Template.GetById(_TestTemplates[0].Id);
            ValidateProperties(tmp, _TestTemplates[0]);
        }
    }
}
